let Mock = require("mockjs");
let express = require("express");
let logger = require("morgan");
let app = express();
app.use(logger("dev"));
app.get("/news", function (req, res) {
  let result = Mock.mock({
    "data|10": [
      {
        id: "@id",
        title: "@csentence",
        url: "@url",
        image: "@image(600X500)",
        createAt: "@datetime",
      },
    ],
  });
  res.json(result);
});
app.get("/cache", function (req, res) {
  res.json({ title: "新闻标题" + Date.now() });
});
app.listen(3000, () => {
  console.log("mock server is running at port 3000");
});
